class Solution {
public:
    int findMaxConsecutiveOnes(vector<int>& nums) {
        int i,m = 0,n= 0;
        for (i = 0; i < nums.size(); i++) {
            if (nums[i] == 1) {
                m++;
            }
            if (nums[i] == 0 || i == nums.size() - 1) {
                n = max(m, n);
                m = 0;
            }
        }
        return n;
    }
};